<?php
include("conn/conn.php");
if(!$_SESSION["telphone"]){
    echo "<script>window.location.href='orderlogin.php';</script>";

  } else if(isset($_POST)&& is_numeric($_POST["telphone"])) {

	$username=$_POST["username"];
	$email = $_POST["email"];
	$gender= $_POST["gender"];
	$tel = $_POST["telphone"];
	$city=$_POST["chengshi"];
	$area=$_POST["xiaoqu"];
	$address = $_POST["address"];
	


	$sql=mysql_query("select count(*) as total from tb_user where tel=".$tel,$conn);
	$info=mysql_fetch_array($sql);
	$total=$info[total];
	if($total==0){
		mysql_query("insert into tb_user (name,truename,xingbie,tel,email,city,area,dizhi) values ('$username','$username','$gender','$tel','$email','$city','$area','$address')",$conn);
		
	}else{

		mysql_query("update tb_user set name='$username',xingbie='$gender', truename='$username',tel='$tel',email='$email',city='$city',area='$area',dizhi='$address' where tel='$tel' ",$conn);
		
	}	
mysql_close($conn);
	$_SESSION["telphone"]=$tel;
	$_SESSION["username"]=$username;

		echo "<script>window.location.href='shopping.php';</script>";
		exit;	
  }
  exit();
?>